library ieee;
use ieee.std_logic_1164.all;

entity entity_name is
  port (
    -- SLIDE SWITCHES

    -- Each slide switch produces a low-level outputs when in the down position
    -- and produces high-level outputs when in the up position.  These
    -- slide switches are *not* debounced.

    sw17, sw16, sw15, sw14, sw13, sw12, sw11, sw10, sw9, sw8, sw7, sw6,
    sw5, sw4, sw3, sw2, sw1, sw0: in std_ulogic;

    -- PUSHBUTTONS

    -- Each pushbutton produces a high-level output when not pressed and
    -- produces a low-level output when pressed.  These pushbuttons *are*
    -- debounced.

    key3, key2, key1, key0: in std_ulogic;

    -- RED LEDS

    -- Each LED is illuminated when driven by a high-level.

    ledr17, ledr16, ledr15, ledr14, ledr13, ledr12, ledr11, ledr10, ledr9,
    ledr8, ledr7, ledr6, ledr5, ledr4, ledr3, ledr2, ledr1, ledr0:
    out std_ulogic;

    -- GREEN LEDS

    -- Each LED is illuminated when driven by a high-level.

    -- NOTE: ledg8 is located between hex4 and hex3.

    ledg8, ledg7, ledg6, ledg5, ledg4, ledg3, ledg2, ledg1, ledg0:
    out std_ulogic;

    -- SEVEN SEGMENT DISPLAYS

    -- Segment map -- These segment numbers correspond to the index used in
    -- each of the following vectors.
    --
    --         0
    --       -----
    --      |     |
    --    5 |     | 1
    --      |  6  |
    --       -----
    --      |     |
    --    4 |     | 2
    --      |     |
    --       -----  O DP
    --         3

    -- The segments and decimal points of the seven-segment LEDs are
    -- illuminated when driven with a low signal.

    hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0:
    out std_ulogic_vector(0 to 6);
    hex7dp, hex6dp, hex5dp, hex4dp, hex3dp, hex2dp, hex1dp, hex0dp:
    out std_ulogic;

    -- 28 MHz, 50 MHz, and EXTERNAL CLOCKS

    clk28mhz: in std_ulogic
    clk50mhz, clk50mhz_2, clk50mhz_3, clk50mhz_4: in std_ulogic
    clkext: in std_ulogic
  );

end entity entity_name;

architecture dataflow of entity_name is
  attribute chip_pin: string;

  --Pin Assignments for Altera DE2-70

  -- Each slide switch produces a low-level outputs when in the down position
  -- and produces high-level outputs when in the up position.  These
  -- slide switches are *not* debounced.

  --Pin Assignments for Slide Switches
  attribute chip_pin of sw17: signal is "L8";  --Leftmost
  attribute chip_pin of sw16: signal is "L7";
  attribute chip_pin of sw15: signal is "L4";
  attribute chip_pin of sw14: signal is "L5";
  attribute chip_pin of sw13: signal is "T9";
  attribute chip_pin of sw12: signal is "U9";
  attribute chip_pin of sw11: signal is "V10";
  attribute chip_pin of sw10: signal is "W5";
  attribute chip_pin of sw9: signal is "AE27";
  attribute chip_pin of sw8: signal is "AD24";
  attribute chip_pin of sw7: signal is "AD25";
  attribute chip_pin of sw6: signal is "AC23";
  attribute chip_pin of sw5: signal is "AC24";
  attribute chip_pin of sw4: signal is "AC26";
  attribute chip_pin of sw3: signal is "AC27";
  attribute chip_pin of sw2: signal is "AB25";
  attribute chip_pin of sw1: signal is "AB26";
  attribute chip_pin of sw0: signal is "AA23";  --Rightmost

  -- Each pushbutton produces a high-level output when not pressed and
  -- produces a low-level output when pressed.  These pushbuttons *are*
  -- debounced.

  --Pin Assignments for Pushbuttons
  attribute chip_pin of key3: signal is "U29";  --Leftmost
  attribute chip_pin of key2: signal is "U30";
  attribute chip_pin of key1: signal is "T28";
  attribute chip_pin of key0: signal is "T29";  --Rightmost

  -- Each LED is illuminated when driven by a high-level.

  --Pin Assignments for Individual Red LEDs
  attribute chip_pin of ledr17: signal is "AJ7";  --Leftmost
  attribute chip_pin of ledr16: signal is "AD8";
  attribute chip_pin of ledr15: signal is "AD9";
  attribute chip_pin of ledr14: signal is "AC11";
  attribute chip_pin of ledr13: signal is "AB12";
  attribute chip_pin of ledr12: signal is "AC12";
  attribute chip_pin of ledr11: signal is "AB13";
  attribute chip_pin of ledr10: signal is "AC13";
  attribute chip_pin of ledr9: signal is "AD14";
  attribute chip_pin of ledr8: signal is "AH3";
  attribute chip_pin of ledr7: signal is "AJ2";
  attribute chip_pin of ledr6: signal is "AJ3";
  attribute chip_pin of ledr5: signal is "AH4";
  attribute chip_pin of ledr4: signal is "AK3";
  attribute chip_pin of ledr3: signal is "AJ4";
  attribute chip_pin of ledr2: signal is "AJ5";
  attribute chip_pin of ledr1: signal is "AK5";
  attribute chip_pin of ledr0: signal is "AJ6";  --Rightmost

  -- Each LED is illuminated when driven by a high-level.

  --Pin Assignments for Individual Green LEDs
  attribute chip_pin of ledg8: signal is ""AC14;  --Between hex4 and hex3

  attribute chip_pin of ledg7: signal is "AA24";  --Leftmost
  attribute chip_pin of ledg6: signal is "AA27";
  attribute chip_pin of ledg5: signal is "Y23";
  attribute chip_pin of ledg4: signal is "Y24";
  attribute chip_pin of ledg3: signal is "Y27";
  attribute chip_pin of ledg2: signal is "W23";
  attribute chip_pin of ledg1: signal is "W25";
  attribute chip_pin of ledg0: signal is "W27";  --Rightmost

  -- Segment map -- These segment numbers correspond to the index used in
  -- each of the following vectors.
  --
  -- The Decimal Point (DP) is accessed via the dp suffix.
  --
  --         0
  --       -----
  --      |     |
  --    5 |     | 1
  --      |  6  |
  --       -----
  --      |     |
  --    4 |     | 2
  --      |     |
  --       -----  O DP
  --         3

  -- The segments and decimal points of the seven-segment LEDs are
  -- illuminated when driven with a low signal.

  --Pin Assignments for Seven-Segment Displays
  attribute chip_pin of hex7dp: signal is "G2";  --Leftmost
  attribute chip_pin of hex7: signal is "K3, J1, J2, H1, H2, H3, G1";  --Leftmost
  attribute chip_pin of hex6dp: signal is "K2";
  attribute chip_pin of hex6: signal is "H6, H4, H7, H8, G4, F4, E4";
  attribute chip_pin of hex5dp: signal is "K6";
  attribute chip_pin of hex5: signal is "M3, L1, L2, L3, K1, K4, K5";
  attribute chip_pin of hex4dp: signal is "L6";
  attribute chip_pin of hex4: signal is "P1, P2, P3, N2, N3, M1, M2";
  attribute chip_pin of hex3dp: signal is "M4";
  attribute chip_pin of hex3: signal is "P6, P4, N10, N7, M8, M7, M6";
  attribute chip_pin of hex2dp: signal is "AC19";
  attribute chip_pin of hex2: signal is "AE7, AF7, AH5, AG4, AB18, AB19, AE19";
  attribute chip_pin of hex1dp: signal is "AC17";
  attribute chip_pin of hex1: signal is "AG13, AE16, AF16, AG16, AE17, AF17, AD17";
  attribute chip_pin of hex0dp: signal is "AF12";  --Rightmost
  attribute chip_pin of hex0: signal is "AE8, AF9, AH9, AD10, AF10, AD11, AD12";  --Rightmost

  --Pin Assignments for Clock Circuitry
  attribute chip_pin of clk28mhz: signal is "E16";
  attribute chip_pin of clk50mhz: signal is "AD15";
  attribute chip_pin of clk50mhz_2: signal is "D16";
  attribute chip_pin of clk50mhz_3: signal is "R28";
  attribute chip_pin of clk50mhz_4: signal is "R3";
  attribute chip_pin of clkext: signal is "R29";
begin
  ledr17 <= sw17;
  ledr16 <= sw16;
  ledr15 <= sw15;
  ledr14 <= sw14;
  ledr13 <= sw13;
  ledr12 <= sw12;
  ledr11 <= sw11;
  ledr10 <= sw10;
  ledr9 <= sw9;
  ledr8 <= sw8;
  ledr7 <= sw7;
  ledr6 <= sw6;
  ledr5 <= sw5;
  ledr4 <= sw4;
  ledr3 <= sw3;
  ledr2 <= sw2;
  ledr1 <= sw1;
  ledr0 <= sw0;

  ledg8 <= key3;

  ledg7 <= key3;
  ledg6 <= key2;
  ledg5 <= key1;
  ledg4 <= key0;

  ledg3 <= key3;
  ledg2 <= key2;
  ledg1 <= key1;
  ledg0 <= key0;

  hex0 <= "0000001";
  hex0dp <= "1";
  hex1 <= "1001111";
  hex1dp <= "0";
  hex2 <= "0010010";
  hex2dp <= "1";
  hex3 <= "0000110";
  hex3dp <= "0";
  hex4 <= "1001100";
  hex4dp <= "1";
  hex5 <= "0100100";
  hex5dp <= "0";
  hex6 <= "0100000";
  hex6dp <= "1";
  hex7 <= "0001111";
  hex7dp <= "0";
end architecture dataflow;
